package com.mvity.framework.common.global;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.mvity.framework.common.base.BaseVO;
import com.mvity.framework.common.utils.JsonUtil;
import com.mvity.framework.common.utils.XmlUtil;

public final class ExtJSGridResponse<E extends BaseVO> implements Serializable, IResponseOutput {

	private static final long serialVersionUID = 4980454642795766464L;

	public static ExtJSGridResponse<BaseVO> emptyDataResponse = new ExtJSGridResponse<BaseVO>(0, new ArrayList<BaseVO>());

	private int total;

	private List<E> data;

	public ExtJSGridResponse() {
	}

	public ExtJSGridResponse(int total, List<E> data) {
		this.total = total;
		this.data = data;
	}

	/**
	 * 返回 total 的值
	 * 
	 * @return total
	 */
	public int getTotal() {
		return total;
	}

	/**
	 * 设置 total 的值
	 * 
	 * @param total
	 */
	public void setTotal(int total) {
		this.total = total;
	}

	/**
	 * 返回 data 的值
	 * 
	 * @return data
	 */
	public List<E> getData() {
		return data;
	}

	/**
	 * 设置 data 的值
	 * 
	 * @param data
	 */
	public void setData(List<E> data) {
		this.data = data;
	}

	@Override
	public String toJsonString() {
		return JsonUtil.beanToJson(this);
	}

	@Override
	public String toXmlString() {
		return XmlUtil.beanToXML(this);
	}
}